package com.talkology.pilot.teacher.service.impl;

import com.talkology.pilot.database.dao.TeacherInfoMapper;
import com.talkology.pilot.database.model.TeacherInfo;
import com.talkology.pilot.teacher.service.ITeacherInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author longjp
 * @since 2018-11-02
 */
@Service
public class TeacherInfoServiceImpl implements ITeacherInfoService {

    @Autowired
    private TeacherInfoMapper teacherInfoMapper;

    @Override
    public List<TeacherInfo> getAllByFilter(String type, Byte pronounce) {
        return this.teacherInfoMapper.selectByType(type, pronounce);
    }

    @Override
    public TeacherInfo getInfo(Long index) {
        return this.teacherInfoMapper.selectByPrimaryKey(index);
    }

    @Override
    @Transactional
    public void add(TeacherInfo teacherInfo) {
        this.teacherInfoMapper.insert(teacherInfo);
    }

    @Override
    @Transactional
    public void edit(TeacherInfo teacherInfo) {
        this.teacherInfoMapper.updateByPrimaryKey(teacherInfo);
    }

    @Override
    @Transactional
    public void delete(Long index) {
        this.teacherInfoMapper.deleteByPrimaryKey(index);
    }
}
